package games.mapacman.common;

import games.mapacman.client.GameScreen;
import games.mapacman.server.MaPacmanZone;
import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import marauroa.common.game.Definition.Type;

public class EatenSign extends Sign {

	protected int x, y;

	public EatenSign(int x, int y, MaPacmanZone zone) {
		disappear = -1;
		myObject = new RPObject();
		myObject.put("type", Constants.TYPE_EATENSIGN);
		myObject.put("x", x);
		myObject.put("y", y);
		myObject.put("delete", 6);
		myObject.put("zoneid", zone.getName());
		this.x = x;
		this.y = y;
		this.zone = zone;
	}

	public EatenSign(RPObject object) {
		disappear = 6;
		myObject = object;
		x = object.getInt("x");
		y = object.getInt("y");
	}

	public static void initRPClass() {
		RPClass sign = new RPClass(Constants.TYPE_EATENSIGN);
		sign.isA("position");
		sign.addAttribute("delete", Type.INT);
	}

	public void draw(GameScreen screen) {
		if (myObject.getInt("delete") < 2) {
			if (disappear > 4) {
				screen.draw(screen.getKillSprite(1), x, y);
			} else {
				screen.draw(screen.getKillSprite(2), x, y);
			}
			disappear--;
		} else {
			screen.draw(screen.getKillSprite(0), x, y);
		}

	}

}
